$(function(){
    $('#searchKeyword').click(function(){
       // alert($(this).val());
        var strs = new Array();
        var search_key = $(".search_layer input").val();
    })

    function getValuesJq(className,getValKey){
        var str = '';
        $.each($(className),function(i,item){
            str += $(item).data(getValKey) + ',';
        });
        if(str.length > 0){
            str = str.substr(0,str.length - 1);
        }
        return str;
    }
    $(".bidding").css('display','none');
    $('#serach_from').submit(function(){
        var cthis = layer.open({type: 2});
        var  keyword,type,theme,dlength,nowprice,isinclude,suffix;
        keyword  = $('.shopping_search input').val();
        type      = getValuesJq('.type_list .active','type');
        suffix    = getValuesJq('.suffix .active','suffix');
        theme     = getValuesJq('.theme .active','theme');
        //dlength   = getValuesJq('.domainslength .list_show','dlength');
        //nowprice  = getValuesJq('.nowprice .list_show','nowprice');
        dlength   = $('#domainslength').val();
        nowprice  = $('#nowprice').val();
        isinclude = getValuesJq('.check .checked','isinclude');
        var post_url = 'index.php?g=Wap&c=Search&a=search';
        var postdata = {
            keyword : keyword,
            type:type,
            theme:theme,
            dlength:dlength,
            nowprice:nowprice,
            isinclude:isinclude,
            suffix:suffix

        };

        $.ajax({
            type: "post",
            url:post_url,
            data:postdata,
            dataType:"json",
            success:function(result){
                // 0议价 yj，1一口价 ykj，2竞价jj，3优质yz
                layer.close(cthis);
                if(result.error){
                    /*layer.open({
                        content: '暂时没有相关数据',
                        btn: ['OK'],
                        shadeClose: true,
                        yes: function(){
                           // window.location.reload();
                        }
                    });
					return false;*/
                }else{
                    var da = result, contets = $('.bidding > ul');
                    $("#serach_from").remove();
                    $(".bidding").css('display','block');
                    //  alert('竞价：'+result[0].domain +'-- 议价：'+result[1].domain);
                    for(i in da){
                        var urls;
                        var  lis ="<li>";
                        if(da[i].type ==0){
                            lis +="<a href=index.php?g=Wap&c=Buydomains&a=detail&id="+da[i].domain_id+"><h4>"+da[i].domain+"</h4>"
                        }else if(da[i].type ==1){
                            lis +="<a href=index.php?g=Wap&c=Hotsale&a=selling&id="+da[i].domain_id+"><h4>"+da[i].domain+"</h4>"
                        }else if(da[i].type ==2){
                            lis +="<a href=index.php?g=Wap&c=Fastbid&a=detail&id="+da[i].domain_id+"><h4>"+da[i].domain+"</h4>"
                        }else if(da[i].type ==3){
                            lis +="<a href=index.php?g=Wap&c=Bargain&a=detail&id="+da[i].domain_id+"><h4>"+da[i].domain+"</h4>"
                        }
                        lis += "<p>"+  da[i].desc + " &nbsp;&nbsp;</p>"
                        lis += "<p><span>"+da[i].money+"元</span><span></span></p></a>"
                        lis += "</li>"
                        contets.append(lis);
                    }
                }

            }
        });
		return false;

    });
});
